package com.bdqn.day0106.mybatis.mapper;

import com.bdqn.day0106.mybatis.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @Author:Corday
 * @Date:2022/01/06/11:27
 * 全注解编程
 */
@Mapper
public interface UserMapper {
    //1.返回id的整型对象
    @Select("select uid from user where uname=#{un} and password=#{pass}")
    Integer selectByUnameAndPassword(@Param("un")String uname,@Param("pass") String password);
    //2.实现用户注册功能
    //2.1先查询select
    @Select("select uid from user where uname=#{uname};")
    Integer selectByUname(String uname);
    //2.2再注册insert
    @Insert("insert into user(uname,password,type) values(#{uname},#{password},#{type})")
    Integer insertUser(User user);
}
